package com.bdqn.t296.noso.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bdqn.t296.noso.entity.ReportVo;
import com.bdqn.t296.noso.service.PrescriService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 处方划价Controller
 */
@Controller
@RequestMapping("/prescri")
public class PrescriController {

    @Autowired
    PrescriService prescriService;

    @RequestMapping("/mobu")
    public Object mobu(Model model) {
        QueryWrapper<ReportVo> wrapper = new QueryWrapper<ReportVo>();//条件构造器
        System.out.println("进入PrescriController");
        wrapper.like("r.reportName", "%" + null + "%");
        //分页对象：查询获得 User 对象，查看第 1 页数据，每页显示 2 条记录
        Page<ReportVo> page = new Page<ReportVo>(1, 2);
        IPage<ReportVo> prescriPager = prescriService.mobu(page, wrapper);
        for (ReportVo reportVo1 : prescriPager.getRecords()) {//获得查询记录
            System.out.println("Name：" + reportVo1.getReportName());
        }
        model.addAttribute("prescriPager", prescriPager);
        return "hospital/ption";
    }

    @RequestMapping("/mobuList")
    @ResponseBody
    public Object mobu(Model model, String durgname) {
        System.out.println("durgname=====" + durgname);
        /*ReportVo reportVo = new ReportVo();
        reportVo.setReportName(durgname);*/
        QueryWrapper<ReportVo> wrapper = new QueryWrapper<ReportVo>();//条件构造器
        wrapper.like("r.reportName", "%" + durgname + "%");
        //分页对象：查询获得 User 对象，查看第 1 页数据，每页显示 2 条记录
        Page<ReportVo> page = new Page<ReportVo>(1, 2);
        IPage<ReportVo> prescriPager = prescriService.mobu(page, wrapper);
        System.out.println("当前记录： -----> ");
        for (ReportVo reportVo1 : prescriPager.getRecords()) {//获得查询记录
            System.out.println("Name：" + reportVo1.getReportName());
        }
        model.addAttribute("prescriPager", prescriPager);
        return prescriPager;
    }
}
